package com.zhentao.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;

/**
 * 组装单明细表，记录组装单的产品明细
 * @TableName assembly_order_item
 */
@TableName(value ="assembly_order_item")
@Data
public class AssemblyOrderItem implements Serializable {
    /**
     * 主键ID，明细的唯一标识，用于在系统中唯一确定一条组装单明细记录
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 组装单ID，关联组装单表的ID，表明该明细属于哪张组装单
     */
    private Long assemblyId;

    /**
     * 产品ID，关联产品表的ID，表明该明细涉及的产品
     */
    private Long productId;

    /**
     * 数量，本次组装该产品的数量
     */
    private BigDecimal quantity;

    /**
     * 类型，表明该产品在组装业务中的角色：
     * INPUT - 输入商品（被合并的商品，库存减少）
     * OUTPUT - 输出商品（合并后的商品，库存增加）
     */
    private String type;

    /**
     * 备注信息，用于记录与该组装明细相关的额外说明，如产品的特殊要求等
     */
    private String remark;
    @TableField(exist = false)
    private String productName;

    @TableField(exist = false)
    private String productCode;
    @TableField(exist = false)
    private String warehouseName;


    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        AssemblyOrderItem other = (AssemblyOrderItem) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getAssemblyId() == null ? other.getAssemblyId() == null : this.getAssemblyId().equals(other.getAssemblyId()))
            && (this.getProductId() == null ? other.getProductId() == null : this.getProductId().equals(other.getProductId()))
            && (this.getQuantity() == null ? other.getQuantity() == null : this.getQuantity().equals(other.getQuantity()))
            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
            && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getAssemblyId() == null) ? 0 : getAssemblyId().hashCode());
        result = prime * result + ((getProductId() == null) ? 0 : getProductId().hashCode());
        result = prime * result + ((getQuantity() == null) ? 0 : getQuantity().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", assemblyId=").append(assemblyId);
        sb.append(", productId=").append(productId);
        sb.append(", quantity=").append(quantity);
        sb.append(", type=").append(type);
        sb.append(", remark=").append(remark);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
